PFont f;
float a1, a2, a3;
int i = 1;
String[] lines;
float radius = 250.0;

Dial axz, ayz, axy, mxz, myz, mxy;


void setup() {
  size(800, 600);
  smooth();
  f = createFont("Serif", 48, true);
  //frameRate(12);

  // locations for the dials
  float x1 = 10 + radius/2;
  float x2 = x1 + 10 + radius;
  float x3 = x2 + 10 + radius;
  float y1 = 10 + radius/2;
  float y2 = y1 + 30 + radius;
  float y3 = y2 + 30 + radius;

  axz = new Dial(x1, y1, radius, "AXZ");
  ayz = new Dial(x2, y1, radius, "AYZ");
  axy = new Dial(x3, y1, radius, "AXY");

  axz.setScale(8000);
  ayz.setScale(8000);
  axy.setScale(8000);

  mxz = new Dial(x1, y2, radius, "MXZ");
  myz = new Dial(x2, y2, radius, "MYZ");
  mxy = new Dial(x3, y2, radius, "MXY");
  
  mxz.setScale(650);
  myz.setScale(650);
  mxy.setScale(650);

  lines = loadStrings("mag.csv");
}

void draw() {
  if (i < lines.length) {
    String[] pieces = split(lines[i], ',');

    // read accel values 
    float ax = int(pieces[7]);
    float ay = int(pieces[8]);
    float az = int(pieces[9]);
    float mx = int(pieces[10]);
    float my = int(pieces[11]);
    float mz = int(pieces[12]);

    mxz.display(mz, mx);
    myz.display(mz, my);
    mxy.display(my, mx);

    axz.display(az, ax);
    ayz.display(az, ay);
    axy.display(ay, ax);

  }
  i++;
}


